home *** CD-ROM | disk | FTP | other *** search
- #Assumptions:
- # 1. 2 input files are passed ( xref, xref targets)
- # 2. NOLINES is passed as a parameter which contains the no. of lines in first input file
- BEGIN { }
- {
-
- if ( NR <= NOLINES ) {
- nf1 = NR ;
- a[NR] = $1 ;
- }
- else {
- nf2 = NR ;
- b[NR-NOLINES] = $1 ;
-
- }
- }
- END {
- nf2 = nf2 - nf1 ;
- # print nf1 nf2
- # for( ind=1 ; ind <= nf1 ; ind ++ ) print a[ind] ;
- # for( ind=1 ; ind <= nf2 ; ind ++ ) print b[ind] ;
- # Values in a[] and b[] are in ascending order
-
- if ( XREFNEEDED == 1 ) {
- k = 0;
- total = 0;
-
- for (i = 1; i <= nf1 ; i ++) {
- for(j = 1 ; j <= nf2 ; j++ ) {
- if (a[i] == b[j] )
- break ;
- else if (a[i] > b[j] )
- continue ;
- else {
- c[++k] = a[i] ;
- total = k ;
- break ;
- }
- }
- }
-
- # printf("Reference IDs outside this book:");
- if ( total > 0 )
- for ( k =1 ; k <= total ; k++)
- printf("%d ",c[k]);
- # else
- # printf("None");
- # printf("\n");
-
- }
-
- else {
-
- # Inter change a[]'s and b[]'s and do the same
-
- k = 0;
- total = 0;
-
-
- for (j = 1; j <= nf2 ; j ++) {
- for(i = 1 ; i <= nf1 ; i++ ) {
- if (a[i] == b[j] )
- break ;
- else if (a[i] < b[j] )
- continue ;
- else {
- c[++k] = b[j] ;
- total = k ;
- break ;
- }
- }
- }
-
- # printf("Target IDs from outside this book:");
- if ( total > 0 )
- for ( k =1 ; k <= total ; k++)
- printf("%d ",c[k]);
- # else
- # printf("None");
- # printf("\n");
-
- }
- }
-